﻿// JavaScript Document
Ext.onReady(function() {
	Ext.QuickTips.init();

	var loginForm = new Ext.form.FormPanel({
		el : 'loginDiv',
		monitorValid : true,
		width : 175,
		height : 58,
		labelWidth : 45,
		border : false,
		labelAlign : 'right',
		defaultType : 'textfield',
		defaults : {
			width : 110,
			allowBlank : false
		},
		items : [{
			fieldLabel : '<span style="color:#6F9F36;font-weight:bold;">用户</span>',
			style : 'color:#66A712;margin-top:3px;',
			name : 'userInfo.userName',
			blankText : '用名不允许为空!'
		}, {
			fieldLabel : '<span style=color:"#6F9F36";font-weight:bold;>密码</span>',
			name : 'userInfo.userPwd',
			style : 'color:#66A712;',
			inputType : 'password',
			blankText : '用户密码不允许为空!'
		}]
	});
	loginForm.render();
	Ext.get('loginBtn').on('click', function() {
		var uName = loginForm.form.el.dom['userInfo.userName'].value;
		var pass = loginForm.form.el.dom['userInfo.userPwd'].value;
		if (uName == "" || pass == "") {
			return;
		} else {
			loginForm.form.submit({
				method:"post",
				url:'blogin.shtml',
				waitTitle : '请稍候',
				waitMsg : '系统正在登录中,请稍候...',
				success : function(form, action) {
					Ext.MessageBox.alert("登录提示", "登录成功!", function(btn) {
						window.location.href = "system/backMain.jsp";
					});

				},
				failure : function(form, action) {
					var msg = '登录失败！';
					Ext.MessageBox.alert("登录提示",msg);
				}
			});
		}

	});
	Ext.get('resetBtn').on('click', function() {
		loginForm.getForm().reset();
	});
});